#!/bin/sh

clean()
{
    rm -rf build
}

do_build()
{
    cd build
    cmake ../
    make
}

rebuild()
{
    clean
    mkdir build
    do_build
}

build()
{
    if [ -d build ]
    then
        do_build
    else
        rebuild
    fi
}

cd Tools/
./date_time_now.sh
cd ../

if [ $# = 1 ]
then
    case $1 in
        "-r") 
        echo "rebuild project now===============>"
        rebuild
        ;;
        "-c") 
        echo "clean project now===============>"
        clean
        ;;
        "--help") 
        echo "./build [-r|-c]"
        echo "  build the project"
        echo "  -c clean the project"
        echo "  -r rebuild the project"
        ;;
    esac
else
    echo "build project now===============>"
    build
fi